package com.bytedance.article.common.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

import com.bytedance.framwork.core.monitor.c;

import org.json.JSONObject;

import inline.NetworkDemo;

public final class g {
    public static e a;

    static {
        a = e.a();
    }

    public static void a(long arg2, long arg4, String arg6, String arg7, String arg8, int arg9, JSONObject arg10) {
        try {
            android.support.design.a.b(arg2, arg4, arg6, arg7, arg8, arg9, arg10);
        } catch (Throwable v0) {
        }
    }

    public static void a(String arg2, int arg3) {
        JSONObject v0 = null;
        JSONObject v1 = null;
        try {
            android.support.design.a.a(arg2, arg3, v0, v1);
        } catch (Throwable v0_1) {
        }
    }

    public static void serviceMonitor(String arg3, int arg4, JSONObject arg5) {
        try {
            if (c.j() == null) {
                com.bytedance.framwork.core.monitor.a.a().a(new com.bytedance.framwork.core.monitor.a.d(arg3, arg4, null, arg5));
                return;
            }

            if (!android.support.design.a.n(arg3)) {
                return;
            }

            android.support.design.a.b(arg3, arg4, null, arg5);
        } catch (Throwable v0) {
        }
    }

    public static void a(String arg1, String arg2) {
        float v0 = 1f;
        try {
            android.support.design.a.a(arg1, arg2, v0);
        } catch (Throwable v0_1) {
        }
    }

    public static void a(String arg1, String arg2, float arg3) {
        try {
            android.support.design.a.b(arg1, arg2, arg3);
        } catch (Throwable v0) {
        }
    }

    public static void a(String arg1, String serviceName, JSONObject arg3) {
        if (arg3 != null) {
            try {
                if (arg3.length() > 0 && !TextUtils.isEmpty(serviceName)) {
                    arg3.put("service_name", serviceName);
                }
            } catch (Throwable throwable) {
            }
        }
        android.support.design.a.a(arg1, arg3);
    }

    public static void a(String arg1, JSONObject jsonObject) {
        try {
            android.support.design.a.a(arg1, jsonObject);
        } catch (Throwable throwable) {
        }
    }

    public static void monitorPerformance(String arg3, JSONObject arg4, JSONObject arg5) {
        try {
            if (c.j() == null) {
                com.bytedance.framwork.core.monitor.a.a().a(new com.bytedance.framwork.core.monitor.a.d(arg3, 0, arg4, arg5));
                return;
            }

            if (!android.support.design.a.n(arg3)) {
                return;
            }

            if (arg4.length() <= 0) {
                return;
            }

            android.support.design.a.b(arg3, 0, arg4, arg5);
        } catch (Throwable throwable) {
        }
    }

    public static void a(boolean arg14) {
        if (c.j() == null) {
            return;
        }

        c v8 = c.j();
        v8.h = arg14;
        Context v0 = v8.a;
        if (!v8.j) {
            return;
        }

        try {
            SharedPreferences sharedPreferences = v0.getSharedPreferences("traffic_monitor_info", 0);
            String v6 = sharedPreferences.getString("net_type", null);
            long v10 = sharedPreferences.getLong("last_total_traffic", -1);
            long v2 = sharedPreferences.getLong("mobile_traffic", -1);
            long v4 = sharedPreferences.getLong("wifi_traffic", -1);
            int v1_1 = sharedPreferences.getInt("traffic_upload_switch", 0);
            if (v6 != null && v1_1 == 1) {
                if (v6.equals("WIFI")) {
                    v4 = v4 + android.support.design.a.f(v0) - v10;
                }

                if (v6.equals("MOBILE")) {
                    v2 = v2 + android.support.design.a.f(v0) - v10;
                }

                if (v8.b != null && (v8.c("traffic_monitor")) && (c.k())) {
                    if (arg14) {
                        if (v4 > 0) {
                            v8.b.c("traffic_monitor", "wifi_traffic_foreground", ((float) ((((double) v4)) / 1024)));
                        }

                        if (v2 > 0) {
                            v8.b.c("traffic_monitor", "mobile_traffic_foreground", ((float) ((((double) v2)) / 1024)));
                        }

                        v8.g = false;
                    } else {
                        if (v8.g) {
//                            goto label_70;
                        }else {

                            if (v4 > 0) {
                                v8.b.c("traffic_monitor", "wifi_traffic_background", ((float) ((((double) v4)) / 1024)));
                            }

                            if (v2 > 0) {
                                v8.b.c("traffic_monitor", "mobile_traffic_background", ((float) ((((double) v2)) / 1024)));
                            }

                            v8.g = true;
                        }
                    }

//                    goto label_70;
                } else if (v8.i != 1) {
//                    goto label_70;
                } else if (arg14) {
                    if (v4 > 0) {
                        c.a("timer", "traffic_monitor", "wifi_traffic_foreground", ((float) ((((double) v4)) / 1024)));
                    }

                    if (v2 <= 0) {
//                        goto label_70;
                    } else {
                        c.a("timer", "traffic_monitor", "mobile_traffic_foreground", ((float) ((((double) v2)) / 1024)));
//                      goto label_70;
                    }
                } else {
                    if (v4 > 0) {
                        c.a("timer", "traffic_monitor", "wifi_traffic_background", ((float) ((((double) v4)) / 1024)));
                    }

                    if (v2 <= 0) {
//                    goto label_70;
                    } else {
                        c.a("timer", "traffic_monitor", "mobile_traffic_background", ((float) ((((double) v2)) / 1024)));
                    }
                }
            }

            label_70:
            v8.p = android.support.design.a.f(v0);
            v8.q = 1;
            v8.m = NetworkDemo.d(v0);
            v8.n = 0;
            v8.o = 0;
            c.a(v0, v8.m, v8.n, v8.o, v8.p, v8.q);
            return;
        } catch (Throwable v0_1) {
            return;
        }
    }

    public static boolean a() {
        return android.support.design.a.o("fps_new_switch");
    }

    public static boolean a(String arg1) {
        return android.support.design.a.m(arg1);
    }

    public static void b(long arg2, long arg4, String arg6, String arg7, String arg8, int arg9, JSONObject arg10) {
        try {
            android.support.design.a.a(arg2, arg4, arg6, arg7, arg8, arg9, arg10);
        } catch (Throwable v0) {
        }
    }
}

